Author Topic: Passing a "library relative path" to ComponentLinknURL in part properties  (Read 3620 times)

0 Members and 1 Guest are viewing this topic.

Offline elwaliTopic starter

  • Newbie
  • Posts: 9
  • Country: sd
Hi All,

I'd a hard time trying to link a datasheet to a part using the ComponentLinknURL option with a library or a project relative path. I'd like to have my projects portable so I've contained a library project and multiple pcb projects in a sigle workspace which resides in a single folder.

Any ideas???
« Last Edit: January 21, 2017, 04:42:45 pm by elwali »
 

Offline kiran_shrestha

  • Regular Contributor
  • *
  • Posts: 62
  • Country: kr
  • Kiran
    • shorted wire
The answer is within your question, you have to make it all in single workspace folder lets say
workspace -> library project -> libraries files
workspace -> mutiple project -> project folders -> project files
 and linking you datasheet ,, don't add them individually, use some supplier and import the parts from then.
-------------------------------------------------------------
Thats all
 

Offline elwaliTopic starter

  • Newbie
  • Posts: 9
  • Country: sd
well, I mentioned datasheet as a supporting document. which could be something else.

the default relative path is the application path, where your installed AD (i.e. "C:\Program Files (x86)\Altium\ADXX"). This doesn't work for me because as I said I'd like to have my work portable. I'm wondering whether there is some environment variables to use like $ProjectPath or $LibraryPath.

I find myself very annoyed by this  >:(
 

Offline technotronix

  • Regular Contributor
  • *
  • Posts: 210
  • Country: us
    • PCB Assembly
 

Offline elwaliTopic starter

  • Newbie
  • Posts: 9
  • Country: sd
After hours of trials, here is my workaround:

First I'd like to state some facts:
- Parameter 'ComponentLinknURL' can accept either absolute file path (local/network) or website address.
- If you enter a file name, AD will start looking for it in DXP.exe path or C:\.
- Windows environment variables was my first idea, but unfortunately they are not recognizable by AD. (at least in this context)

The only way I see is to modify the parameter's value each time you move your workspace, which is a nightmare of course.
I wrote a VB script to do the job and now I'm able to port my workspace on different computers.

My workspace hierarchy:
Level1---->                                                              Workspace[Dir.]
Level2---->      LIB[Dir.]         ScriptsProj[Dir.]     PCBProj1[Dir.]       PCBProj2[Dir.]   ...    PCBProjn[Dir.]
Level3---->  Datasheets[Dir]

I've used a VB script form with 4 labels to display process summery, you only need to run it once on the new computer.
since both ComponentLinknURL and HelpURL parameters can be used for datasheet reference, I've picked HelpURL for the F1 key feature. (pressing F1 is easier than 3 mouse clicks)
The script will:
1- construct the current datasheet directory path.
2- extract datasheet file names from HelpURL for each part in all schematic documents in workspace.
3- modify HelpURL for each part in all schematic documents in workspace.
4- display process summery.
If some documents got modified, you must save them manually (I didn't get there yet).
////////////////////////////////////////////////////////////////////////////////////////
Sub Form1Create(Sender)
    Dim Project
    Dim Doc
    Dim Sheet
    Dim Components
    Dim Parameters
    Dim Array
    Dim Path
    Dim DocCount
    Dim SchCount
    Dim Count
    Dim ParVal

    ' Get Current Workspace Path (full path includes workspace name, I had to split it to get parent dir, no substring here!!)
    Array = Split(GetWorkSpace.DM_WorkspaceFullPath,"\")
    For i=0 To UBound(Array)-1
        Path = Path & Array(i) & "\"
    Next
    Path = Path & "LIB\Datasheets\"

    Count = 0
    DocCount = 0
    SchCount = 0
    Label1.Caption = "Total Projects: " & GetWorkSpace.DM_ProjectCount
    For i=0 To GetWorkSpace.DM_ProjectCount-1
        Project = GetWorkSpace.DM_Projects(i)
        ' Check if Project is flattened (if project is flattened (compiled before) we don't need to show the schmatic document, only loading it is ok)
        Set flatHierarchy = Project.DM_DocumentFlattened
        If flatHierarchy Is Nothing Then
           Project.DM_Compile
        End If
        DocCount = DocCount + Project.DM_LogicalDocumentCount
        For j=0 To Project.DM_LogicalDocumentCount-1
            Doc = Project.DM_LogicalDocuments(j)
            IF Doc.DM_DocumentKind = "SCH" Then
                SchCount = SchCount + 1
                Client.OpenDocument "Sch",Doc.DM_FullPath
                Set Sheet = SchServer.GetSchDocumentByPath(Doc.DM_FullPath)
                SchServer.ProcessControl.PreProcess Sheet,""
                Components = Sheet.SchIterator_Create
                Components.AddFilter_ObjectSet(MkSet(eSchComponent))
                Set Component = Components.FirstSchObject
                While Not (Component IS Nothing )
                    Parameters = Component.SchIterator_Create
                    If Not (Parameters Is Nothing) Then
                        Parameters.AddFilter_ObjectSet(MkSet(eParameter))
                        Set Parameter = Parameters.FirstSchObject
                        While  Not (Parameter IS Nothing)
                            If Parameter.Name = "HelpURL" Then
                               ParVal = Trim(Parameter.Text)
                                If ParVal <> "" And InStr(ParVal, "www.") < 1 And InStr(ParVal, ":\\") < 1 Then
                                   Array = Split(ParVal, "\")
                                   ParVal = Path & Array(UBound(Array))
                                   If Parameter.Text <> ParVal Then
                                      SchServer.RobotManager.SendMessage Parameter.I_ObjectAddress, c_BroadCast, SCHM_BeginModify, c_NoEventData
                                      Parameter.Text = Path & Array(UBound(Array))
                                      SchServer.RobotManager.SendMessage Parameter.I_ObjectAddress, c_BroadCast, SCHM_EndModify  , c_NoEventData
                                      Count = Count + 1
                                   End If
                                End If
                            End If
                            Set Parameter = Parameters.NextSchObject
                        WEnd
                        Component.SchIterator_Destroy(Parameters)
                    End If
                    Set Component = Components.NextSchObject
                WEnd
                Sheet.SchIterator_Destroy(Components)
            End If
            SchServer.ProcessControl.PostProcess Sheet,""
        Next
    Next
    Set Component = Nothing
    Set Parameter = Nothing
    Label2.Caption = "Total Documents: " & DocCount
    Label3.Caption = "Total Schematics: " & SchCount
    Label4.Caption = "Modified Parts: " & Count
End Sub
////////////////////////////////////////////////////////////////////////////////////////

Sorry for the mess, it's my first VB script.
I really hope there is an easier way.

Notes and remarks are welcomed  :)
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf