Passing a "library relative path" to ComponentLinknURL in part properties - Page 1
Forum section: electronics / general

author: elwali
author_rank: Newbie
timestamp: January 18, 2017, 05:45:24 pm
content: 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???

author: kiran_shrestha
author_rank: Regular Contributor
timestamp: January 19, 2017, 12:11:41 am
content: The answer is within your question, you have to make it all in single workspace folder lets sayworkspace -> library project -> libraries filesworkspace -> mutiple project -> project folders -> project filesand linking you datasheet ,, don't add them individually, use some supplier and import the parts from then.

author: elwali
author_rank: Newbie
timestamp: January 19, 2017, 02:14:42 am
content: 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

author: technotronix
author_rank: Regular Contributor
timestamp: January 20, 2017, 12:04:44 pm
content: This may help you to use environment variable.http://techdocs.altium.com/display/ADRR/Sch_Obj-Parameter((Parameter))_AD

author: elwali
author_rank: Newbie
timestamp: January 21, 2017, 04:38:11 pm
content: 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----> DatasheetsI'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 ProjectDim DocDim SheetDim ComponentsDim ParametersDim ArrayDim PathDim DocCountDim SchCountDim CountDim 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)-1Path = Path & Array(i) & "\"NextPath = Path & "LIB\Datasheets\"Count = 0DocCount = 0SchCount = 0Label1.Caption = "Total Projects: " & GetWorkSpace.DM_ProjectCountFor i=0 To GetWorkSpace.DM_ProjectCount-1Project = 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_DocumentFlattenedIf flatHierarchy Is Nothing ThenProject.DM_CompileEnd IfDocCount = DocCount + Project.DM_LogicalDocumentCountFor j=0 To Project.DM_LogicalDocumentCount-1Doc = Project.DM_LogicalDocuments(j)IF Doc.DM_DocumentKind = "SCH" ThenSchCount = SchCount + 1Client.OpenDocument "Sch",Doc.DM_FullPathSet Sheet = SchServer.GetSchDocumentByPath(Doc.DM_FullPath)SchServer.ProcessControl.PreProcess Sheet,""Components = Sheet.SchIterator_CreateComponents.AddFilter_ObjectSet(MkSet(eSchComponent))Set Component = Components.FirstSchObjectWhile Not (Component IS Nothing )Parameters = Component.SchIterator_CreateIf Not (Parameters Is Nothing) ThenParameters.AddFilter_ObjectSet(MkSet(eParameter))Set Parameter = Parameters.FirstSchObjectWhile Not (Parameter IS Nothing)If Parameter.Name = "HelpURL" ThenParVal = Trim(Parameter.Text)If ParVal <> "" And InStr(ParVal, "www.") < 1 And InStr(ParVal, ":\\") < 1 ThenArray = Split(ParVal, "\")ParVal = Path & Array(UBound(Array))If Parameter.Text <> ParVal ThenSchServer.RobotManager.SendMessage Parameter.I_ObjectAddress, c_BroadCast, SCHM_BeginModify, c_NoEventDataParameter.Text = Path & Array(UBound(Array))SchServer.RobotManager.SendMessage Parameter.I_ObjectAddress, c_BroadCast, SCHM_EndModify , c_NoEventDataCount = Count + 1End IfEnd IfEnd IfSet Parameter = Parameters.NextSchObjectWEndComponent.SchIterator_Destroy(Parameters)End IfSet Component = Components.NextSchObjectWEndSheet.SchIterator_Destroy(Components)End IfSchServer.ProcessControl.PostProcess Sheet,""NextNextSet Component = NothingSet Parameter = NothingLabel2.Caption = "Total Documents: " & DocCountLabel3.Caption = "Total Schematics: " & SchCountLabel4.Caption = "Modified Parts: " & CountEnd Sub////////////////////////////////////////////////////////////////////////////////////////Sorry for the mess, it's my first VB script.I really hope there is an easier way.Notes and remarks are welcomed