Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DropDownCommand trouble

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
StephenCim-001
235 Views, 3 Replies

DropDownCommand trouble

Hi All 😞

 

I though I had dropdown lists worked out.  but I was wrong.

 

I gave up on the groupradiobuttons for now and decided to use another dropdown list.\

I have these 4 dropdown controls.

inputs = command.commandInputs
_standard = inputs.addDropDownCommandInput('standard', 'Select Conuntry', adsk.core.DropDownStyles.TextListDropDownStyle)

_ringsizesAustralia = inputs.addDropDownCommandInput('ringsizeAustralia', 'Select Ring Size',       adsk.core.DropDownStyles.TextListDropDownStyle)
_ringsizesUSA = inputs.addDropDownCommandInput('ringsizeUSA', 'Select Ring Size', adsk.core.DropDownStyles.TextListDropDownStyle)
_profile = inputs.addDropDownCommandInput('profile', 'Select Ring Profile', adsk.core.DropDownStyles.TextListDropDownStyle)

 

_Standard has 2 list items, _ringsizesUSA  has 15 list items , _ringsizesAustralia has 18 list items and  _profile has 2 list items

 

 

 

now in my onexecute event handler I have ..

 

eventArgs = adsk.core.CommandEventArgs.cast(args)

# Get the root component of the active design.

if _standard.selectedItem.name == 'USA':
     ringsizeinput = _ringsizesUSA.selectedItem.name
     ringsize = USARINGSIZES[ringsizeinput]
     ringstandard = _standard.selectedItem.name
elif _standard.selectedItem.name == 'Australian':
    ringsizeinput = _ringsizesAustralia.selectedItem.name
    ringsize = OZRINGSIZES[ringsizeinput]
     ringstandard = _standard.selectedItem.name
else:
      ringsize = '20mm'
      ringstandard = 'Custom'

 

if _profile.selectedItem.name == 'Half Circle':
     _selectedprofile = 1
elif _profile.selectedItem.name == 'Full Circle':
     _selectedprofile = 2
else:
     _selectedprofile = 0

 

 

The first group of if,elif,else statements work fine, I have no trouble working with the selected items

But when I try to work with the _profile dropdown list I get a 

 

if _profile.selectedItem.name == 'Half Circle': : AtributeError : 'NoneType' has no attribute 'selectedItem'

Most of the code was copy and paste  😞  what am I doing wrong?  

 

Cheers, Stephen

 

 

3 REPLIES 3
Message 2 of 4
p.seem
in reply to: StephenCim-001

Stephen,

 

I don't see anything obviously wrong with the snippet you've posted.  Unless someone can see something I don't, I'd suggest posting the whole script, or at least as much of it as you are able.  It looks like _profile hasn't been initialized, so your problem is more likely to be the snippet where it is defined/declared (does it have the right scope?)/initialized/retrieved than where you actually call _profile.selectedItem.

 

PS

Message 3 of 4
StephenCim-001
in reply to: p.seem

I'll post my code, but it's ugly, real ugly  😉  I haven't coded in 30 years and that was  straight C on an embedded 80186 🙂 .  

 

Any help would be most appreciated  🙂

 

Cheers, Stephen

Message 4 of 4
p.seem
in reply to: StephenCim-001

Stephen,

 

Don't worry about ugly, that's what this forum is all about.  I've been coding for 20 years straight and my code is still ugly.

 

I confess I haven't tried to run your code so I might be wrong, but it looks like the problem is in SingleStoneRingPressedEventHandler.  On the line (198) where you declare your global variables, you've left _profile off the list.  So the "_profile" variable that create and populate in that function is a local one, and not the same as the "_profile" you are accessing in ringDialogOKEventHandler.  

 

I hope that helps?

 

PS

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report